import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2024-03-13
 * Time: 20:56
 */
class Test {
    public static int missingNumber(int[] num) {
        Arrays.sort(num);
        int left = 0, right = num.length-1;
        while(left < right) {
            int mid = left + (right-left)/2;
            if(num[mid] == mid) {
                left = mid + 1;
            }else {
                right = mid;
            }
        }
        if(num[left] == left) {
            return left+1;
        }
        return left;
        //细节 边界条件
    }

    public static void main(String[] args) {
        int[] array = {0,1,2,4,5,6};
        int a =  missingNumber(array);
        System.out.println(a);
    }
}
